<template>
	<view>
		<uni-list v-for="(item,index) in list">
			<view @longpress="longpress(item.id)">
				<uni-list-item clickable :title="item.RecodNum" :show-badge="true" :badge-text="item.count" link
					:to="'../inputbodylist/inputbodylist?id='+item.id+'&WarehouseId='+item.WarehouseId" :note="item.RecodDate"></uni-list-item>
			</view>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.$api.Request({
				url: "/api/input/GetInputHeadList",
				method: 'GET',
				data: {},
			}).then((res) => {

				res.forEach(item => {

					this.list.push({
						id: item.Id,
						RecodNum: item.RecodNum,
						RecodDate: this.$dateformat.dateFormat(item.RecodDate, 'date'),
						count: item.BodyCount,
						WarehouseId: item.WarehouseId,
					})
				});

			})


		},
		methods: {

			onNavigationBarButtonTap() {
				uni.navigateTo({
					url: '../inputheadadd/inputheadadd'
				})
			},

			longpress(id) {
				var me = this;
				uni.showModal({
					title: '删除',
					content: '请问要删除本条消息吗？',
					success: function(res) {
						if (res.confirm) {
							me.$api.Request({
								url: "/api/input/DeleteHead?keyValue=" + id,
								method: 'GET',

							}).then((res1) => {

								if (res1.state == 'success') {
									uni.showToast({
										title: `删除成功`
									})
									location.reload();

								} else {
									uni.showToast({
										title: `删除失败`,
										icon:'error',
									})

								}

							})
						}

					}
				});
			},
		},

	}
</script>

<style>

</style>
